<?
include_once 'functions.php';
$dbh=dbConn();

$id = $_GET['id'];

if(!isset($id))
{ echo mysql_error(); }

else
{
  $sql = "SELECT * FROM human_resources WHERE id=$id";
  
  $result = mysql_query($sql, $dbh);
//  $data = mysql_result($result, 0, "cv");
//  $name = mysql_result($result, 0, "name");
//  $size = mysql_result($result, 0, "cvsize");
//  $type = mysql_result($result, 0, "cvtype");
 $path = mysql_result($result, 0, "cv");
 $name = trim($path, "cvs/");
 
 header("Content-Type: application/unknown");
 header("Content-Disposition: attachment; filename=$name");

		// open the file for reading and start dumping it to the browser
		if($fp = fopen($path, "r")) 
		{
			while(!feof($fp)) 
			{ echo  fgets($fp, 4096);}
			
			// close the file
			fclose($fp);
		}

 // header("Content-type: $type");
 // header("Content-length: $size");
 // header("Content-Disposition: attachment; filename=$name");
 // echo $data;
 // http_send_file($path);

dbClose($dbh);
exit;
}

?>
